<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('提交请假审核')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-leave-submit" th:object="${recordLeave}">
            <input name="leaveId" th:field="*{leaveId}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label">人员类型：</label>
                <div class="form-control-static" th:if="*{userType == '01'}">
                    普通职工
                </div>
                <div class="form-control-static" th:if="*{userType == '02'}">
                    中层及以上
                </div>
            </div>
            <div class="form-group" th:if="*{userType == '02'}">
                <label class="col-sm-3 control-label">代理人：</label>
                <div class="form-control-static" th:text="*{agentUser}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">休假类型：</label>
                <div class="form-control-static" th:text="*{@dict.getLabel('record_leave_type', leaveType)}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">请假事由：</label>
                <div class="form-control-static" th:text="*{leaveContent}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">开始时间：</label>
                <div class="form-control-static" th:text="*{#dates.format(startTime, 'yyyy-MM-dd')}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">结束时间：</label>
                <div class="form-control-static" th:text="*{#dates.format(endTime, 'yyyy-MM-dd')}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">天数：</label>
                <div class="form-control-static" th:text="*{days}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="form-control-static" th:text="*{remark}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">科主任（护士长）：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="chiefId" name="chiefId" type="hidden" th:field="*{chiefId}" />
                        <input class="form-control" type="text" onclick="selectUserTree('chief')" id="chiefName" name="chiefName" th:field="*{chiefName}" readonly="true">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">主管科室负责人：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="manageId" name="manageId" type="hidden" th:field="*{manageId}" />
                        <input class="form-control" type="text" onclick="selectUserTree('manage')" id="manageName" name="manageName" th:field="*{manageName}" readonly="true">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">人事科负责人：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="humanId" name="humanId" type="hidden" th:field="*{humanId}" />
                        <input class="form-control" type="text" onclick="selectUserTree('human')" id="humanName" name="humanName" th:field="*{humanName}" readonly="true">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">主管科室分管领导：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="leaderId" name="leaderId" type="hidden" th:field="*{leaderId}" />
                        <input class="form-control" type="text" onclick="selectUserTree('leader')" id="leaderName" name="leaderName" th:field="*{leaderName}" readonly="true">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group" th:if="*{userType == '02'}">
                <label class="col-sm-3 control-label">行政领导：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="adminId" name="adminId" type="hidden" th:field="*{adminId}" />
                        <input class="form-control" type="text" onclick="selectUserTree('admin')" id="adminName" name="adminName" th:field="*{adminName}" readonly="true">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group" th:if="*{userType == '02'}">
                <label class="col-sm-3 control-label">党委书记：</label>
                <div class="col-sm-8">
                    <div class="input-group">
                        <input id="partyId" name="partyId" type="hidden" th:field="*{partyId}" />
                        <input class="form-control" type="text" onclick="selectUserTree('party')" id="partyName" name="partyName" th:field="*{partyName}" readonly="true">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "record/leave"
        var verifyType = '';
        /* 选择人员 */
        function selectUserTree(type) {
            verifyType = type;
            var options = {
                title: '选择员工',
                width: "380",
                url: ctx + "basic/user/selectTree",
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            var body = layer.getChildFrame('body', index);
            var verifyId = "#" + verifyType + "Id";
            var verifyName = "#" + verifyType + "Name";
            var id = body.find('#treeId').val();
            var treeId = id.substring(id.indexOf('_') + 1, id.length);
            var name = body.find('#treeName').val();
            var treeName = name.substring(0, name.indexOf('('));
            $(verifyId).val(treeId);
            $(verifyName).val(treeName);
            layer.close(index);
        }

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/submit", $('#form-leave-submit').serialize());
            }
        }
    </script>
</body>
</html>